<?php


namespace App\Imports;

use App\Models\Attendance;
use Encore\Admin\Facades\Admin;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;

/**
 * Created By FreeAbrams
 * 考勤汇总表导入
 * Date: 2020/11/27
 */
class Attendances implements ToModel, WithStartRow
{
	protected $import_time = '';
	
	public function __construct($import_time)
	{
		$this->import_time = $import_time;
	}
	
	public function startRow(): int
	{
		return 5;
	}
	
	public function model(array $row)
	{
		$store_id = Admin::user()->store_id;
		return new Attendance([
				'store_id' => $store_id,
			    'import_time' => $this->import_time,
			    'staff_id' => $row[0],
			    'name' => $row[1],
			    'department' => $row[2],
			    'base_working_time' => $row[3],
				'actual_working_time' => $row[4],
				'skip' => $row[5],
			    'skip_grade' => $row[6],
			    'live_earl' => $row[7],
			    'live_earl_grade' => $row[8],
			    'base_exploited_times' => $row[9],
			    'special_exploited_times' => $row[10],
			    'base_actual_days' => $row[11],
			    'travel_days' => $row[12],
			    'skip_work_days' => $row[13],
			    'leave_days' => $row[14],
			    'work_rate' => $row[15],
			    'salary_remark' => $row[16],
			    'exploited_salary' => $row[17],
			    'add_salary' => $row[18],
			    'late_reduce' => $row[19],
			    'leave_reduce' => $row[20],
			    'reduce_salary' => $row[21],
			    'actual_salary' => $row[22],
			    'remark' => $row[23]
		]);
	}
}